package models;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import play.data.validation.Required;
import play.db.jpa.Model;

@Entity
@Table(name = "Actions")
public class Action extends Model {

	@Required
	public String name;
	
	@Required
	@Lob
	public String description;

	@ManyToMany(mappedBy = "actions")
	public List<Role> roles = new LinkedList<Role>();

	/**
	 * Constructs a new Action
	 * @param name
	 * @param description
	 * 
	 */
	public Action(String name, String description)
	{
		super();
		this.name = name;
		this.description = description;
	}
	
	/**
	 * Defines the String representation of the Action
	 * 
	 */
	public String toString() {
	    return name;
	}
}
